<div class="section">
    <?php
    echo $this->element('toolbar');
    ?>
    <?php
    $isModuleBlock = empty($this->request->data['Block']['custom']);

    echo $this->Form->create('Block', array('id' => 'paginate', 'action' => 'edit', 'url' => $this->request->here(false), 'type' => 'post',
        'inputDefaults' => array('label' => false, 'format' => array('before', 'label', 'between', 'input', 'after', 'error'))));

    // hidden on debug = 0
    if (Configure::read('debug')) {
        $_layouts = array_merge(array(array(
                'Module Config',
                array(array('module', 'delta')))), $_layouts);

        $modules = Configure::read('Modules');
        $modules = array_combine(array_keys($modules),Set::classicExtract($modules, '{s}.name'));
        $fieldsets['module'] = $this->Form->input('module', array(
            'label' => __d('system', 'Module'),
            'onchange' => "$('#BlockCustom').val($(this).val() != '0' ? 0 : 1)",
            'options' => array_merge(array('0' => __d('system', 'Custom')), $modules),
            'type' => 'select'));

        $fieldsets['delta'] = $this->Form->input('delta', array(
            'label' => __d('system', 'Delta'),
            'type' => 'text'));
    }

    $fieldsets['title'] = $this->Form->input('title', array(
        'label' => __d('system', 'Title'),
        'type' => 'text'));

    if ($isModuleBlock) {
        $fieldsets['title'] .= $this->Html->div('colcomment', __d('system', 'Override the default title for the block. Use <none> to display no title, or leave blank to use the default block title.'));
    } else {
        $fieldsets['title'] .= $this->Html->div('colcomment', __d('system', 'The title of the block as shown to the user.'));
    }

    $fieldsets['description'] = $this->Form->input('description', array(
        'label' => __d('system', 'Description'),
        'type' => 'text'));
    $fieldsets['description'] .= $this->Html->div('colcomment', __d('system', 'A brief description of your block. Used on the Blocks administration page.'));

    if ($isModuleBlock) {
        $fieldsets['content'] = '';
    } else {
        $fieldsets['content'] = $this->Form->input('content', array(
            'label' => __d('system', 'Content'),
            'type' => 'textarea'));
        $fieldsets['content'] .= $this->Html->div('colcomment', __d('system', 'The content of the block as shown to the user.'));
    }

    $fieldsets['include'] = $this->Form->input('include', array(
        'label' => __d('system', 'Show block on specific pages'),
        'type' => 'textarea'));
    $fieldsets['include'] .= $this->Html->div('colcomment', __d('system', 'Specify pages by using their paths. Enter one path per line. The \'*\' character is a wildcard. Example paths are blog for the blog page and /blog/* for every personal blog. <front> is the front page'));

    $fieldsets['exclude'] = $this->Form->input('exclude', array(
        'label' => __d('system', 'Hide block on specific pages'),
        'type' => 'textarea'));
    $fieldsets['exclude'] .= $this->Html->div('colcomment', __d('system', 'Specify pages by using their paths. Enter one path per line. The \'*\' character is a wildcard. Example paths are blog for the blog page and /blog/* for every personal blog. <front> is the front page'));

    $fieldsets['language'] = $this->Form->input('language', array(
        'label' => __d('system', 'Show block on specific language'),
        'multiple' => 'checkbox',
        'options' => $this->Layout->listLanguages(),
        'type' => 'select'));

    $fieldsets['role_id'] = $this->Form->input('Role', array(
        'label' => __d('system', 'Show block on specific roles'),
        'multiple' => 'checkbox',
        'options' => $roles,
        'type' => 'select'));
    ?>

    <div class="panel clearfix">
        <fieldset>
            <?php
            echo $this->Layout->form($_layouts, $fieldsets);
            ?>
        </fieldset>
    </div>
    <?php
    echo $this->Form->input('custom', array('style' => 'display:none;','type'=>'text', 'div' => false));
    echo $this->Form->hidden('Paginate.task', array('id' => 'task', 'value' => ''));
    echo $this->Form->end();
    ?>
</div>